﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WJP.Queue.Socketing.Framing
{
    /// <summary>
    /// 消息帧组建接口
    /// </summary>
    public interface IMessageFramer
    {
        /// <summary>
        /// 解析帧数据，当数据完全到达后触发回调方法
        /// </summary>
        /// <param name="data"></param>
        void UnFrameData(IEnumerable<ArraySegment<byte>> data);

        /// <summary>
        /// 解析帧数据，当数据完全到达后触发回调方法
        /// </summary>
        /// <param name="data"></param>
        void UnFrameData(ArraySegment<byte> data);

        /// <summary>
        /// 组装帧数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        IEnumerable<ArraySegment<byte>> FrameData(ArraySegment<byte> data);

        /// <summary>
        /// 注册消息完全到达后回调方法
        /// </summary>
        /// <param name="handler"></param>
        void RegisterMessageArrivedCallback(Action<ArraySegment<byte>> handler);
    }
}
